using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CashierSystem.UserManager;

namespace CashierSystem
{
    public partial class LoginForm : Form
    {
        private bool result = false;
        private User user;
        public LoginForm()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            result = false;
            this.Close();
        }
        public bool getResult()
        {
            return result;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string userAccount = account.Text;
            string pass = password.Text;
            user = UserManagerAction.validUser(userAccount, pass);
            if (user != null)
            {
                result = true;
                this.Close();
            }
        }
        public User getUser()
        {
            return user;
        }

        private void password_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.button1.Focus();
                button1_Click(this, new EventArgs());
            }
        }

    }
}